package com.security.Utils;

import com.security.system.entity.SysUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * 获取当前登录用户信息 工具类
 * 2020-3-31
 * gdy
 */
public class UserContextUtils {

    /*获取当前登录用户信息*/
    public SysUser getUser(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        Object principal = authentication.getPrincipal();
        SysUser user = (SysUser)principal;
        return user;
    }

}
